# -*- coding: utf-8 -*-

#################
#    Imports    #
#################
import sys
import os


def is_frozen():
    """
    All of the modules are built-in to the interpreter, e.g., by py2exe
    """
    return hasattr(sys, "frozen")


def normalize_path(path):
    """
    Normalizes a path
    """
    encoding = sys.getfilesystemencoding()
    return os.path.normpath(unicode(path, encoding))


def module_path():
    """
    Gets the module path in proper way
    """
    encoding = sys.getfilesystemencoding()
    if is_frozen():
        return os.path.dirname(unicode(sys.executable, encoding))
    return os.path.dirname(unicode(__file__, encoding))


def module_abspath(*path):
    """
    Join module absolute path with another path
    path -- Path to join to the absolute module path
    """

    return os.path.normpath(os.path.join(module_path(), *path))